package org.example.friend.controller.exam;

import org.example.common.core.controller.BaseController;
import org.example.common.core.domain.Result;
import org.example.common.core.domain.ResultTable;
import org.example.friend.domain.exam.dto.ExamQueryDTO;
import org.example.friend.domain.exam.dto.ExamRankDTO;
import org.example.friend.service.exam.ExamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/exam")
public class ExamController extends BaseController {

    @Autowired
    private ExamService examService;

    @GetMapping("/semiLogin/list")
    public ResultTable list(ExamQueryDTO examQueryDTO) {
        return examService.list(examQueryDTO);
    }

    @GetMapping("/rank/list")
    public ResultTable rankList(ExamRankDTO examRankDTO) {
        return examService.rankList(examRankDTO);
    }

    @GetMapping("/getFirstQuestion")
    public Result<String> getFirstQuestion(Long examId) {
        return Result.ok(examService.getFirstQuestion(examId));
    }

    @GetMapping("/preQuestion")
    public Result<String> preQuestion(Long examId, Long questionId) {
        return Result.ok(examService.preQuestion(examId, questionId));
    }

    @GetMapping("/nextQuestion")
    public Result<String> nextQuestion(Long examId, Long questionId) {
        return Result.ok(examService.nextQuestion(examId, questionId));
    }
}
